package com.power.sifa.approve.model;


import com.plf.core.base.model.Ha_attachment;
import com.plf.core.common.annotations.FieldEnumText;
import com.plf.core.common.domain.BaseModel;
import com.power.sifa.approve.model.enumeration.St_apply;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.stereotype.Component;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 申请人实体类
 */

@Entity
@ApiModel(value = "申请人")
@Data
@Table(name = "Apl_applicant", schema = "sfapprove")
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@Component
//@IdClass(Apl_applicant.Apl_applicantPK.class) 用于复合组件
public class Apl_applicant extends BaseModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @Setter(AccessLevel.NONE)
    @ApiModelProperty(value = "applyid+nanoid")
    private String id;

    @ApiModelProperty(value = "applyid")
    private String applyid;

    @ApiModelProperty(value = "申请人类型")
    private Integer type;

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "证件类型")
    private Integer cardtype;

    @ApiModelProperty(value = "证件号")
    private String cardno;

    @ApiModelProperty(value = "联系地址")
    private String addr;

    @ApiModelProperty(value = "联系电话")
    private String tel;

    @ApiModelProperty(value = "邮政编码")
    private String postcode;

    @ApiModelProperty(value = "法定代表人或主要负责人")
    private String manager;

    @ApiModelProperty(value = "工作单位")
    private String unit;

    @ApiModelProperty(value = "民族")
    private Integer nation;

    @ApiModelProperty(value = "性别")
    private Integer gender;

    @ApiModelProperty(value = "是否代表人")
    private Integer isrepr;

    @ApiModelProperty(value = "排序")
    private Integer sortnum = 0;

    @ApiModelProperty(value = "代理人id")
    private String agentid;

    @ApiModelProperty(value = "出生年月")
    private String birthym;

    @ApiModelProperty(value = "工作")
    private String job;

    @ApiModelProperty(value = "身份证明")
    private String filecard;

    @ApiModelProperty(value = "身份证明书")
    private String doccard;

    @ApiModelProperty(value = "身份证明附件详情")
    @Transient
    private List<Ha_attachment> filecardList;

    @ApiModelProperty(value = "身份证明书详情")
    @Transient
    private List<Ha_attachment> doccardList;

    @Transient
    @ApiModelProperty(value = "提交时间")
    private String subtime;

    @Transient
    @ApiModelProperty(value = "案件号")
    private String acceptcode;

    @Transient
    @ApiModelProperty(value = "状态")
    private Integer status = St_apply.ACCEPT;

    @Transient
    @ApiModelProperty(value = "申请人")
    private String applyname;

    @Transient
    @ApiModelProperty(value = "被申请人")
    private String targetname;


    /**
     * 申请人关联的代理人
     */
    @Transient
    private List<Apl_agent> agentList;

    /**
     * 申请人类型文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_applicant", valuefield = "type")
    private String type_text;

    /**
     * 证件类型文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_card", valuefield = "cardtype")
    private String cardtype_text;

    /**
     * 民族文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_nation", valuefield = "nation")
    private String nation_text;

    /**
     * 性别文本
     */
    @Transient
    @FieldEnumText(eum = "Tp_gender", valuefield = "gender")
    private String gender_text;

    /**
     * 是否代表人文本
     */
    @Transient
    @FieldEnumText(eum = "yesNo", valuefield = "isrepr")
    private String isrepr_text;


    public Map<String, Object> parseMap() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", this.getId());
        map.put("applyid", this.getApplyid());
        map.put("type_text", this.type_text);
        map.put("type", this.getType());
        map.put("name", this.getName());
        map.put("cardtype_text", this.cardtype_text);
        map.put("cardtype", this.getCardtype());
        map.put("cardno", this.getCardno());
        map.put("addr", this.getAddr());
        map.put("tel", this.getTel());
        map.put("postcode", this.getPostcode());
        map.put("manager", this.getManager());
        map.put("unit", this.getUnit());
        map.put("nation_text", this.nation_text);
        map.put("nation", this.getNation());
        map.put("gender_text", this.gender_text);
        map.put("gender", this.getGender());
        map.put("job", this.getJob());
        map.put("isrepr_text", this.isrepr_text);
        map.put("isrepr", this.getIsrepr());
        map.put("sortnum", this.getSortnum());
        map.put("agentid", this.getAgentid());
        map.put("birthym", this.getBirthym());
        map.put("subtime", this.getSubtime());
        map.put("acceptcode", this.getAcceptcode());
        map.put("status", this.getStatus());
        map.put("applyname", this.getApplyname());
        map.put("targetname", this.getTargetname());


        return map;
    }

    public String getId() {
        return id;
    }

    public void setId(Serializable id) {
        this.id = (String) id;
    }

    public Serializable getPrimaryKey() {
        return id;
        // return new Apl_applicantPK(id, id2); 用于复合主键，请手动创建内部静态类
    }

    public void setPrimaryKey(Serializable key) {
        this.id = (String) key;

        //Apl_applicantPK pk = (Apl_applicantPK) key; 用于复合主键
        //this.id = pk.getId();
        //this.id2 = pk.getId2();
    }

}
